<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>对象展开</title>
</head>
<body>
<script>
    /*
      Rest 参数在 spread 扩展运算符在 ES6 中已经引入，不过 ES6 中只针对数组
      在 ES9 中为对象提供了向数组一样的 rest 参数和扩展运算符
    */

    // 1. 解构赋值
    function connect({host, post, ...user}) { //...user --- 将剩余的属性保存在user对象中
        console.log(host, post, user)
    }

    connect({
        host: '127.0.0.1',
        post: '9000',
        username: 'admin',
        password: 'admin'
    });

    // 2. 合并对象
    const firstName = {
        name: '张三'
    }
    const secondName = {
        age: 15
    }
    const thirdName = {
        sex: '男'
    }
    const fourthName = {
        phone: '125468735'
    }
    console.log({...firstName, ...secondName, ...thirdName, ...fourthName})

</script>
</body>
</html>